/**
 * @param {character[][]} board
 * @return {boolean}
 */
var isValidSudoku = function (board) {
  let arrX = [];
  let arrY = [];
  let arrZ = [];
  for (let i = 0; i < 9; i++) {
    let b = board[i];
    for (let j = 0; j < 9; j++) {
      let val = b[j];
      if (val === '.') {
        continue;
      }
      val = Number(val) - 1;
      let x = i * 9 + val;
      if (arrX[x]) {
        return false;
      }
      let y = j * 9 + val;
      if (arrY[y]) {
        return false;
      }
      let z = (Math.floor(j / 3) + Math.floor(i / 3) * 3) * 9 + val;
      if (arrZ[z]) {
        return false;
      }
      arrX[x] = true;
      arrY[y] = true;
      arrZ[z] = true;
    }
  }
  return true;
};
